import { api, safe } from '@/lib/api'; import { fmtInt } from '@/lib/format'; import { OG_CONTENT_TYPE, OG_SIZE, renderSiteOg, renderTopicOg } from '@/lib/og'; import { SITE_NAME } from '@/lib/site'; /** Country share image: name, region, monitored companies, activity counters. */ export const alt = `Country on ${SITE_NAME}`; export const size = OG_SIZE; export const contentType = OG_CONTENT_TYPE; export default async function CountryOpenGraphImage({ params }: { params: Promise<{ code: string }> }) { const { code } = await params; const d = await safe(api.country(code.toUpperCase())); if (!d) return renderSiteOg(await safe(api.stats())); const list = Array.isArray(d.companies) ? d.companies : []; const count = Array.isArray(d.companies) ? d.companies.length : d.companies; const industries = (d.industries ?? []).length; return renderTopicOg({ eyebrow: d.region ? `Country ยท ${d.region}` : 'Country', title: d.name, subtitle: `Companies headquartered in ${d.name}, observed continuously on their public web surfaces.`, names: list.map((c) => c.display_name), counters: [ ['Companies', fmtInt(count)], ['Events 7d', fmtInt(d.events_7d)], ['Events 30d', fmtInt(d.events_30d)], ['Industries', fmtInt(industries)], ], path: `/country/${d.code.toLowerCase()}`, }); }